#pragma once

#include "afxpropertygridctrl.h"

class IBoundedNumberPairProperty;
class CBoundedNumberPairItem;
class CBoundedNumberPairProperty : public CMFCPropertyGridProperty
{
	DECLARE_DYNAMIC(CBoundedNumberPairProperty)

public:
	CBoundedNumberPairProperty(const CString& strName, intptr_t x, intptr_t y, bool showButton, IBoundedNumberPairProperty * iDelegate,
			DWORD_PTR dwData = 0, LPCWSTR xName = nullptr, LPCWSTR yName = nullptr);
	CBoundedNumberPairProperty(const CString& strName, const CPoint & p, bool showButton, IBoundedNumberPairProperty * iDelegate,
			DWORD_PTR dwData = 0, LPCWSTR xName = nullptr, LPCWSTR yName = nullptr)
		:CBoundedNumberPairProperty(strName, p.x, p.y, showButton, iDelegate, dwData, xName, yName) {};
	CBoundedNumberPairProperty(const CString& strName, const COleVariant &p, bool showButton, IBoundedNumberPairProperty * iDelegate,
			DWORD_PTR dwData = 0, LPCWSTR xName = nullptr, LPCWSTR yName = nullptr)
		:CBoundedNumberPairProperty(strName, (p.lVal >> 16) & 0xffffl, p.lVal & 0xffffl, showButton, iDelegate, dwData, xName, yName) {};
	void SetRange(int xmin, int xmax, int ymin, int ymax);
	void OnClickButton(CPoint point) override;
	void OnClickName(CPoint point) override;
	BOOL OnClickValue(UINT uiMsg, CPoint point) override;
	BOOL OnUpdateValue() override;
	const CPoint GetPointValue();
	const CPoint GetOriginalPointValue();
	void SetPointValue(const CPoint &p);
	void SetOriginalPointValue(const CPoint &p);
	void ResetOriginalValue();
	IBoundedNumberPairProperty *getDelegate(){ return m_delegate; }
protected:
	CBoundedNumberPairItem *m_ItemX, *m_ItemY;
	IBoundedNumberPairProperty *m_delegate;
};

class CBoundedNumberPairItem : public CMFCPropertyGridProperty
{
	DECLARE_DYNAMIC(CBoundedNumberPairItem)
public:
	CBoundedNumberPairItem(CBoundedNumberPairProperty * parent, const CString& strName, const COleVariant& varValue);
	void OnClickName(CPoint point) override;
	BOOL OnClickValue(UINT uiMsg, CPoint point) override;
	BOOL OnUpdateValue() override;
protected:
	CBoundedNumberPairProperty *m_pParent;
};

class IBoundedNumberPairProperty
{
public:
	virtual void OnClickButton(CBoundedNumberPairProperty * caller) = 0;
	virtual void OnClickName(CBoundedNumberPairProperty * caller) = 0;
	virtual void OnClickValue(CBoundedNumberPairProperty * caller) = 0;
	virtual void OnUpdateValue(CBoundedNumberPairProperty * caller) = 0;
};

